/*
*******************************************************************************
*                    Copyright (c) 2013, TQ System
*                             All Rights Reserved
*
* Purpose           : COM file
* File Name         : PUBLIC.H

* Revision history  :
    01a,2018/05/16,Ryan  -- Creation(written)

* Description       :

*******************************************************************************
*/
#include <pthread.h>
#include "public.h"
#ifndef _AP_NATIVEUART_INCLUDED_
#define _AP_NATIVEUART_INCLUDED_


#define PACKED __attribute__((aligned(1),packed)) 


typedef struct{
	INT8U        startFlag;
	INT8U        packetLength[2];
	INT8U        packetNum[2];
	INT8U        devId;
	INT8U        packetCmd;
	INT8U        packetAnswer;
}__attribute__((packed)) COM_HEAD_TYPE;

typedef union
{
    unsigned char   buffer[1050];
    COM_HEAD_TYPE   head;
} COM_TYPE;

typedef union         
{                     
	INT16U    word;
	INT8U    byte[2];
} UNION_2_BYTE;

#define PACKET_HEAD_LEN (sizeof(COM_HEAD_TYPE))

#define HIGH_ORDER          1          
#define LOW_ORDER           0
#define mCmd_startFlag      0x7e
#define mCmd_endFlag        0x7e
#define mCmd_getData        0x01      
#define mCmd_setData        0x02       
#define mCmd_report         0x03  

#define mRsp_success        0x00        

#define mRsp_condition      0x01       
#define mRsp_cmdError       0x02   
#define SET_FLAG            0X01
#endif

